import axios from "axios";




/* AddCard页接口 Start */
export interface coupon {
    id?: number,
    name?: string,
    userType?: number,
    money?: number,
    minPrice?: number,
    isFixedTime?: boolean,
    useStartTime?: string,
    useEndTime?: string,
    day?: number,
    total?: number,
    userNum?: number,
    status?: boolean
} 
let addCard=async(_data:coupon)=>{
    let data=await axios({
        url:'/coupon/add',
        method:'post',
        data:_data
    })
    return data
}
/* AddCard页接口 End */


/* CardList页接口 Start */
//优惠券查询

export interface findDto {
    type:string,
    status:boolean,
    name:string,
    page:number,
    limit:number
}
let findCard=async(_data:findDto)=>{
    let data= await axios({
        url:'/coupon/find',
        method:'get',
        params: _data
    })
    return data
}

//删除优惠券
let delCoupon=async(_data:{
    id:number
})=>{
    console.log('data',_data);
    let data= await axios({
        url:'/coupon/deleted',
        method:'post',
        params: _data
    })
    return data
}
//批量删除优惠券
let delCoupons=async(_data:{
    ids:number[]
})=>{
    console.log('data',_data);
    let data= await axios({
        url:'/coupon/deletes',
        method:'post',
        params: _data
    })
    return data
}

let putCoupon=async(_data:{
    id:number,
    limit:number,
    name:string,
    page:number,
    status:number
    uid:number
})=>{
    let data=await axios({
        url:'/coupon/user/insert',
        method:'post',
        data:_data
    })
    return data
}

// //会员查询
let findVIP=async(_data:{
    sex:string,
    startDate:string,
    endDate:string
})=>{
    let data=await axios({
        url:'/youhuiquan',
        method:'get',
        params:_data
    })
    return data
}
//会员分页（批量投放）
let VIPPage=async(_data:{
    pageSize:number,
    pageNumber:number
})=>{
    let data=await axios({
        url:'/youhuiquan',
        method:'get',
        params:_data
    })
    return data
}

/* CardGetList页接口 Start */
let getList=async(_data:{
    page?:number,
    limit?:number,
    nickname?:string,
    status?:number,
    startTime?:Date,
    endTime?:Date,
    couponId?:string,
    uid?:string
})=>{
    let data=await axios({
        url:'/coupon/user/get/list',
        method:'get',
        params:_data
    })
    return data
}
/* CardGetList页接口 End */
export { findCard,delCoupon,delCoupons,putCoupon,addCard,getList,VIPPage,findVIP}